﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace DO.Common
{
	public static class DreamOnConfig
	{
		private static string xmlPath = @"C:\DreamOn.xml";

		private static string _connectionString_web = "";
		public static string connectionString_web
		{ get { return _connectionString_web; } }
		
		private static string _logFolder = "";
		public static string logFolder
		{ get { return _logFolder; } }

		private static string _billFolder = "";
		public static string billFolder
		{ get { return _billFolder; } }

		private static string _url_webBill = "";
		public static string url_webBill
		{ get { return _url_webBill; } }

		//private static string _path_webBill = "";
		//public static string path_webBill
		//{ get { return _path_webBill; } }

		static DreamOnConfig()
		{
			try
			{
				XmlDocument doc = new XmlDocument();
				doc.Load(xmlPath);
				_connectionString_web = doc.SelectSingleNode("DreamOn/connectionString_web").InnerText;
				_logFolder = doc.SelectSingleNode("DreamOn/logFolder").InnerText;
				_billFolder = doc.SelectSingleNode("DreamOn/billFolder").InnerText;
				_url_webBill = doc.SelectSingleNode("DreamOn/url_webBill").InnerText;
				//_path_webBill = doc.SelectSingleNode("DreamOn/path_webBill").InnerText;
			}
			catch (Exception ee)
			{
				throw new Exception("開啟或讀取 " + xmlPath + " 發生錯誤。" + ee.ToString());
			}
		}

		public static string getXmlNodeInnerText(string XPath,string node)
		{
			XmlDocument doc = new XmlDocument();
			doc.Load(XPath);
			return doc.SelectSingleNode(node).InnerText;
		}
	}
}
